package cn.jaye.fabric.common.interceptor;

/**
 * @author Jaye
 * @create 2017-12-25 11:16
 */

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SecurityInterceptor implements HandlerInterceptor {


    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
//        request.getSession().setAttribute("username", Global.TEST_USERNAME);
//        request.getSession().setAttribute("password", Global.TEST_PASSWORD);
//        request.getSession().setAttribute("orgId", Global.TEST_ORGID);
        String username = (String) request.getSession().getAttribute("username");
        if (username != null && StringUtils.isNotBlank(username)) {
        }
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
                           ModelAndView modelAndView) throws Exception {
        // TODO Auto-generated method stub

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
            throws Exception {
        // TODO Auto-generated method stub

    }

}
